home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / blit / bitmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-18  |  3.5 KB  |  126 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: bitmap.h,v 4.2 88/07/19 14:17:18 sau Exp $
  9.     $Source: /tmp/mgrsrc/src/blit/RCS/bitmap.h,v $
  10. */
  11. static char    h_bitmap_[] = "$Source: /tmp/mgrsrc/src/blit/RCS/bitmap.h,v $$Revision: 4.2 $";
  12.  
  13. /* header file for SUN bitmap operations */
  14.  
  15. #ifndef Min
  16. #define Min(x,y)    ((x)>(y)?y:x)
  17. #endif
  18.  
  19. typedef int *DATA;
  20.  
  21. #define bit_blit(dest,dx,dy,width,height,func,source,sx,sy)  \
  22.     mem_rop(dest,dx,dy,width,height,func,source,sx,sy) 
  23.  
  24. #define bit_static(name,wide,high,data,n)    \
  25.     BITMAP name = {(DATA) data, &name, 0, 0, wide, high, _STATIC};
  26. #define NULL_DATA    ((DATA) 0)
  27.  
  28. #define BIT_NULL    ((BITMAP *) 0)
  29.  
  30. #define IS_SCREEN(x)    ((x)->type==_SCREEN)
  31. #define IS_MEMORY(x)    ((x)->type==_MEMORY)
  32. #define IS_PRIMARY(x)    ((x)->primary == (x))
  33.  
  34. /*
  35.  * OPCODE(expr), where expr is boolean expression involving SRC and DST,
  36.  * is one of sixteen numbers encoding a rasterop opcode.
  37.  */
  38.  
  39. #define            DST     0xA    /* 1010 */ /* same as f_dest */
  40. #define            SRC    0xC    /* 1100 */ /* same as f_source */
  41. #define OPCODE(expr)    (0xF&(expr))
  42.  
  43. /* names for common bitblit functions */
  44.  
  45. #ifndef BIT_NOT
  46. #   define BIT_NOT(x)    (~(x))
  47. #endif
  48. #define BIT_SRC        SRC
  49. #define BIT_DST        DST
  50. #define BIT_SET        (BIT_SRC|BIT_NOT(BIT_SRC))
  51. #define BIT_CLR        (BIT_SRC&BIT_NOT(BIT_SRC))
  52. #define BIT_XOR        (BIT_SRC^BIT_DST)
  53. #define BIT_INVERT    (BIT_NOT(DST))
  54. #define GET_OP(x)    ((x)&0xf)
  55.  
  56. /* change rop function for white-on-black */
  57.  
  58. #define ROP_INVERT(x)    GET_OP(rev_ops[0xf&(x)])
  59.  
  60. /* bitmap types */
  61.  
  62. #define _SCREEN        1        /* frame buffer */
  63. #define _MEMORY        2        /* malloc'd space */
  64. #define _STATIC        3        /* don't free space at destroy time */
  65.  
  66. /* member access macros */
  67.  
  68. #define BIT_X(x)    x->x0
  69. #define BIT_Y(x)    x->y0
  70. #define BIT_DATA(x)    x->data
  71. #define BIT_WIDE(x)    x->wide
  72. #define BIT_HIGH(x)    x->high
  73. #define BIT_DEPTH(x)    1        /* no color support for now */
  74.  
  75.  
  76. /* bit mask for bitmap data padding */
  77.  
  78. #define BITS    31L
  79.  
  80. /* BIT_SIZE(map) == the number of chars needed to store the data of the bitmap.
  81.    Usually used with malloc(3).
  82. */
  83.  
  84. #define BIT_SIZE(m)     BIT_Size(BIT_WIDE(m), BIT_HIGH(m), BIT_DEPTH(m)) /* bytes */
  85.  
  86. /* BIT_Size(wide,high,depth) = the number of chars needed to store the data of a
  87.    bitmap of the given number of bits wide high and deep.
  88.        Typical usage:
  89.         char    bitbuffer[ Bit_Size(16,16,1) ];
  90. */
  91.  
  92. #define BIT_Size(wide,high,d)     ((d)*((wide+BITS)&~BITS)*high>>3) /* bytes */
  93.  
  94. #define BIT_LINE(x)     ((x->primary->wide+BITS)&~BITS) /* lng aligned (bits)*/
  95.  
  96. /* structure and type definitions */
  97.  
  98. typedef struct bitmap {
  99.    DATA    data;        /* bitmap data */
  100.    struct bitmap    *primary;    /* pointer to primary bitmap */
  101.    short        x0, y0;        /* starting coordinates, in bits.
  102.                                 0, 0  ==  upper left corner of screen */
  103.    short        wide, high;    /* bitmap size, in bits */
  104.    unsigned short    type;        /* bitmap type */
  105.    } BITMAP;
  106.  
  107. /* function declarations */
  108.  
  109. int mem_rop();
  110. int bit_destroy();
  111. int bit_line();
  112. BITMAP * bit_create();
  113. BITMAP * bit_alloc();
  114. BITMAP * bit_open();
  115.  
  116. /* for non existant color support */
  117.  
  118. #define DEPTH                1            /* bits per pixel */
  119. #define NOCOLOR         0xF
  120. #define GETCOLOR(x)     0
  121. #define PUTCOLOR(x)     0
  122.  
  123. /* other */
  124.  
  125. #define Bprintf(x)    /* gone */
  126.